<%--
  Created by IntelliJ IDEA.
  User: lkx18775339631
  Date: 2022/3/19
  Time: 13:11
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>

    <%--抽取分页条公共部分，以后别的模块需要用分页条，只需在其模块的servlet程序中修改url,在其jsp包含即可--%>
    <div id="page_nav">
        <c:if test="${requestScope.page.pageNo > 1}">
            <a href="${requestScope.page.url}&pageNo=1">首页</a>
            <a href="${requestScope.page.url}&pageNo=${ requestScope.page.pageNo-1 }">上一页</a>
        </c:if>

        <a href="${requestScope.page.url}&pageNo=${requestScope.page.pageNo-1}">${ requestScope.page.pageNo-1==0?"":requestScope.page.pageNo-1 }</a>
        【${ requestScope.page.pageNo }】 	<%--当前页码--%>
        <a href="${requestScope.page.url}&pageNo=${requestScope.page.pageNo+1}">${ requestScope.page.pageNo==requestScope.page.pageTotal?"":requestScope.page.pageNo+1 }</a>

        <%--如果当前页是最后一页就不显示末页和下一页--%>
        <c:if test="${requestScope.page.pageNo < requestScope.page.pageTotal}">
            <a href="${requestScope.page.url}&pageNo=${ requestScope.page.pageNo+1 }">下一页</a>
            <a href="${requestScope.page.url}&pageNo=${ requestScope.page.pageTotal }">末页</a>
        </c:if>

        共${ requestScope.page.pageTotal }页，${ requestScope.page.pageTotalCount }条记录
        到第<input value="${param.pageNo}" name="pn" id="pn_input"/>页
        <input id="searchPageBtn" type="button" value="确定">

        <script type="text/javascript">
            $(function (){
                $("#searchPageBtn").click(function (){
                    var pageNo = $("#pn_input").val();
                    /**
                     * javaScript语言提供有一个location地址栏对象
                     * 他有一个href属性可以 获取或者修改 浏览器地址栏中的地址
                     */
                    if(pageNo <= ${requestScope.page.pageTotal} && pageNo >= 1 ){
                        location.href = "${pageContext.getAttribute("basePath")}${requestScope.page.url}&pageNo="+pageNo;
                    }else {
                        alert("不存在该页面！");
                    }
                });
            });
        </script>
    </div>
